Skip to content

refactor: useFetchEntityInfo uses new getNodeByID endpoint BED-8742#2958

Open
urangel wants to merge 1 commit into
mainfrom
BED-8742
Open

refactor: useFetchEntityInfo uses new getNodeByID endpoint BED-8742#2958
urangel wants to merge 1 commit into
mainfrom
BED-8742

Conversation

@urangel

@urangel urangel commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Description

The useFetchEntityInfo hook is updated to use the getNodByID endpoint to retrieve entity information instead of the cypher search endpoint.

Motivation and Context

Resolves BED-8742

This refactor will enable OG entity info support by routing through an endpoint that will return info section information derived from extension managed schemas.

How Has This Been Tested?

Unit tests have been updated and the change was verified locally.

Screenshots (optional):

Types of changes

  • Chore (a change that does not modify the application functionality)

Checklist:

Summary by CodeRabbit

  • Bug Fixes
    • Improved entity info loading for nodes whose type isn’t in the schema, ensuring the UI correctly displays the “unknown kind” information.
    • Switched entity details fetching to direct node-by-ID retrieval when a database ID is available, improving data accuracy on refresh (including OpenGraph values).
  • Tests
    • Updated entity info and details tab tests to mock the node-by-ID API flow instead of graph/Cypher-based responses.

@urangel urangel self-assigned this Jul 6, 2026
@urangel urangel added the javascript Pull requests that update javascript code label Jul 6, 2026
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 5e3a227f-8c77-4c08-b613-1591c64d1791

📥 Commits

Reviewing files that changed from the base of the PR and between c7e8832 and 3ff94ac.

📒 Files selected for processing (5)
  • packages/javascript/bh-shared-ui/src/components/EntityInfo/EntityInfoContent.test.tsx
  • packages/javascript/bh-shared-ui/src/hooks/useFetchEntityInfo/useFetchEntityInfo.test.tsx
  • packages/javascript/bh-shared-ui/src/hooks/useFetchEntityInfo/useFetchEntityInfo.tsx
  • packages/javascript/bh-shared-ui/src/utils/entityInfoDisplay.ts
  • packages/javascript/bh-shared-ui/src/views/PrivilegeZones/Details/SelectedDetailsTabs/SelectedDetailsTabContent.test.tsx
💤 Files with no reviewable changes (1)
  • packages/javascript/bh-shared-ui/src/utils/entityInfoDisplay.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/javascript/bh-shared-ui/src/components/EntityInfo/EntityInfoContent.test.tsx
  • packages/javascript/bh-shared-ui/src/views/PrivilegeZones/Details/SelectedDetailsTabs/SelectedDetailsTabContent.test.tsx
  • packages/javascript/bh-shared-ui/src/hooks/useFetchEntityInfo/useFetchEntityInfo.test.tsx

📝 Walkthrough

Walkthrough

The hook now fetches database-backed entity data with getNodeByID, keeps schema-based node-type lookups unchanged, removes the Cypher helper, and updates tests and mocks to use /api/v2/nodes/:id.

Changes

Node lookup refactor

Layer / File(s) Summary
Hook query logic and helper removal
packages/javascript/bh-shared-ui/src/hooks/useFetchEntityInfo/useFetchEntityInfo.tsx, packages/javascript/bh-shared-ui/src/utils/entityInfoDisplay.ts
useFetchEntityInfo now branches on databaseId to call apiClient.getNodeByID, falls back to entityInformationEndpoints[validatedKind] for nodeType, or returns empty results otherwise; informationAvailable and the removed Cypher helper/import are updated accordingly.
Test updates for node-by-id fetches
packages/javascript/bh-shared-ui/src/hooks/useFetchEntityInfo/useFetchEntityInfo.test.tsx, packages/javascript/bh-shared-ui/src/components/EntityInfo/EntityInfoContent.test.tsx, packages/javascript/bh-shared-ui/src/views/PrivilegeZones/Details/SelectedDetailsTabs/SelectedDetailsTabContent.test.tsx
Mocks, MSW handlers, spies, and assertions move from Cypher/graph responses to /api/v2/nodes/:id, and the off-schema test description is updated to match the new endpoint.

Estimated code review effort: 2 (Simple) | ~12 minutes

Possibly related PRs

  • SpecterOps/BloodHound#2917: Includes OpenGraph entity-panel loading changes that touch the same entity-info path and the PrivilegeZones object-details test.
  • SpecterOps/BloodHound#2940: Adds the getNodeByID client method and response types used by this refactor.

Suggested labels: api, user interface

Suggested reviewers: elikmiller, catsiller

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the refactor to use getNodeByID for useFetchEntityInfo and includes the linked ticket.
Description check ✅ Passed The description covers the change, motivation, testing, type, and checklist, matching the required template closely.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch BED-8742

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added the user interface A pull request containing changes affecting the UI code. label Jul 6, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/javascript/bh-shared-ui/src/hooks/useFetchEntityInfo/useFetchEntityInfo.test.tsx`:
- Around line 40-46: The `useFetchEntityInfo.test.tsx` setup is double-mocking
`apiClient.getNodeByID`, so `entityNodeByIdRequest` never intercepts anything
and the MSW handler is unused. Update the test to either unmock `apiClient` for
the case that should exercise `/api/v2/nodes/:id`, or remove
`entityNodeByIdRequest` if the test should stay fully mocked; keep the existing
`useFetchEntityInfo` and `getNodeByID` test names aligned with the chosen
approach.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 0a4529df-5918-4c34-9ee5-1f598ba43f69

📥 Commits

Reviewing files that changed from the base of the PR and between f78f8d1 and bf07b9b.

📒 Files selected for processing (4)
  • packages/javascript/bh-shared-ui/src/components/EntityInfo/EntityInfoContent.test.tsx
  • packages/javascript/bh-shared-ui/src/hooks/useFetchEntityInfo/useFetchEntityInfo.test.tsx
  • packages/javascript/bh-shared-ui/src/hooks/useFetchEntityInfo/useFetchEntityInfo.tsx
  • packages/javascript/bh-shared-ui/src/utils/entityInfoDisplay.ts
💤 Files with no reviewable changes (1)
  • packages/javascript/bh-shared-ui/src/utils/entityInfoDisplay.ts

@urangel urangel force-pushed the BED-8742 branch 2 times, most recently from e6a480f to 8678bd2 Compare July 6, 2026 15:45
@coderabbitai coderabbitai Bot added the api A pull request containing changes affecting the API code. label Jul 6, 2026
if (validatedKind) {
({ signal }) => {
if (databaseId) {
return apiClient.getNodeByID(Number(databaseId), { signal }).then((res) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it redundant to perform an additional validations on databaseId to ensure a valid ID before reaching backend?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question. The type of databaseId is defined as string | undefined so the property may or may not be available depending on the context in which one is trying to load entity information. This may have changed since this code was written originally so I'll double check but that is why the validation is happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api A pull request containing changes affecting the API code. javascript Pull requests that update javascript code user interface A pull request containing changes affecting the UI code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants